Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Move formerly global variables in Adafruit_DHT driver into readDHT function #72

Closed
wants to merge 1 commit into from

Conversation

DanielCasner
Copy link

This program is intended to be used as an example and as a basis for people to write new programs. Without this fix, calling readDHT more than once in a program will eventually lead to a buffer overrun error.

In general global variables are dangerous and should especially be avoided in example code.

…nction so that when people use this program as a template and try to call readDHT multiple times, they don't have terrible buffer overrun errors.
@natcl
Copy link

natcl commented Apr 25, 2014

I've been experiencing crashes on my DHT equipped pi for a while now, basically, the more often I read, the sooner it will crash. Could this be related ?

@DanielCasner
Copy link
Author

Seems very likely. This patch fixes a memory overflow I found when modifying the code for my own use. The Adafruit library version only does one read per invocation of the program but it's possible (depending on how the kernel on the RaspberryPi cleans up memory from old processes) that it could cause a crash in the stand alone program as well if it's called often. Sadly I haven't had any response to my pull request.

@natcl
Copy link

natcl commented Apr 25, 2014

I'm mistaken, I'm using the python version (which relies on c code also) but the c code seems different than the pure C version. In any case the Python version seems to crash after a while also...

@tdicola
Copy link
Contributor

tdicola commented May 31, 2014

Thanks for sending the pull request and apologies for someone not getting to it sooner. I'll close this pull since the fix for #80 should stop the immediate issue with crashing because of the buffer overflow. I agree though as an illustrative example it's probably best to pull the debug info out--I want to check with a few folks to see if there's any strong argument for keeping the debug info first though.

@tdicola tdicola closed this May 31, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants